#include<bits/stdc++.h>
using namespace std;

char ans[101];

void check(string s)
{
	memset(ans, ' ', sizeof ans);
	deque<pair<int, char>> dq;
	
	for(int i = 0;i < s.size();i++)
	{
		if(s[i] == '(')
			dq.push_front({i, s[i]});
		else if(s[i] == ')')
		{
			if(dq.empty())
				ans[i] = '?';
			else
				dq.pop_front();
		}
	}
	
	for(auto i = dq.begin();i != dq.end();i++)
		ans[i->first] = '$';
	
	cout<<s<<endl;
	for(int i = 0;i < s.size();i++)
		cout<<ans[i];
	cout<<endl;
}

int main()
{
	
	string  s;
	while(cin>>s)
	{
		check(s);
	}
	return 0;
}

